package gui;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JButton;

public class PositionButton extends JButton 
{
	private static final long serialVersionUID = 1L;
	
	Color d_legalMoveColor = null;
	Color d_chosenMoveColor = null;
	
	public PositionButton(String title) 
	{
		super(title);
	}

	public void paint(Graphics g)
	{
		super.paint(g);
		
		int w = getWidth();
		int h = getHeight();
		int i_w = (int)(0.2*w);
		int i_h = (int)(0.2*h);
		if(d_legalMoveColor != null)
		{//draw circle
			g.setColor(d_legalMoveColor);
			g.drawOval(i_w, i_h, w - 2*i_w, h - 2*i_h);
		}
		if(d_chosenMoveColor != null)
		{//draw cross
			g.setColor(d_chosenMoveColor);
			g.drawLine(i_w,     i_h, w - i_w, h - i_h);
			g.drawLine(i_w, h - i_h, w - i_w,     i_h);
		}
	}

	public void setLegalMove(Color color) 
	{
		d_legalMoveColor = color;
	}

	public void setChosenMove(Color color) 
	{
		d_chosenMoveColor = color;
	}

}
